let videoCallback = function(r){};
require("../AnyThinkAds/ATJSSDK"); 
//如果需要通过开发者的服务器进行奖励的下发（部分广告平台支持服务器激励），则需要传递下面两个key
//ATRewardedVideoJSSDK.userIdKey必传，用于标识每个用户;ATRewardedVideoJSSDK.userDataKey为可选参数，传入后将透传到开发者的服务器
// setting[ATRewardedVideoJSSDK.userIdKey] = "test_user_id";
// setting[ATRewardedVideoJSSDK.userDataKey] = "test_user_data";

class ADS{
    //初始化下东西
    // placementCustomMap = {
    //     "placementCustomKey1": "placementCustomValue1",
    //     "placementCustomKey2" : "placementCustomValue2"
    // };
    constructor(){
        // ATJSSDK.setPlacementCustomMap(customPlacementId, placementCustomMap);
       
    }
    //初始化广告方法
    initAds(){
        if(cc.sys.isNative){
            // ATJSSDK.setLogDebug(true);
            // ATJSSDK.initSDK("a6098dcc2b65d5", "f0b22d9a956154f3d71568d05d015fda");
            //test
            ATJSSDK.initSDK("a6098dcc2b65d5", "f0b22d9a956154f3d71568d05d015fda");
        }
        let rewardedVideoListener = {
            //广告加载成功
            onRewardedVideoAdLoaded:function(placementId) {
                ATJSSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdLoaded(" + placementId + ")");
            },
            //广告加载失败
            onRewardedVideoAdFailed : function(placementId, errorInfo) {
              ATJSSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdFailed(" + placementId + ", " + errorInfo + ")");
            },
            //广告开始播放
            onRewardedVideoAdPlayStart : function(placementId, callbackInfo) {
               ATJSSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayStart(" + placementId + ", " + callbackInfo + ")");
            },
            //广告播放结束
            onRewardedVideoAdPlayEnd : function(placementId, callbackInfo) {
                ATJSSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayEnd(" + placementId + ", " + callbackInfo + ")");
            },
            //广告播放失败
            onRewardedVideoAdPlayFailed : function(placementId, errorInfo, callbackInfo) {
                ATJSSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayFailed(" + placementId + ", " + errorInfo + ", " + callbackInfo + ")");
            },
            //广告被关闭
            onRewardedVideoAdClosed : function() {
                Video.loadAds();
            },
            //广告被点击
            onRewardedVideoAdPlayClicked : function(placementId, callbackInfo) {
                ATJSSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayClicked(" + placementId + ", " + callbackInfo + ")");
            },
            //激励成功，开发者可在此回调中下发奖励，一般先于onRewardedVideoAdClosed回调，服务器激励则不一定
            onReward : function(placementId, callbackInfo){
                Video.cb(placementId, callbackInfo)
            }
        }
        if(cc.sys.isNative){
            ATRewardedVideoJSSDK.setAdListener(rewardedVideoListener);
        }

    }
    //显示广告

}

module.exports.ADS = new ADS();